package com.opennetexam.manager.common;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * @author 奶茶
 * 排列组合对外方法
 * Created by on 2017/11/29.
 */
public class OpenCombinations {

    /**
     * 乱序:返回int型的数组
     * @param count
     * @return
     */
    public static Integer[] showPermutations(Integer count){
        List<Integer> list = new ArrayList<>();
        for (int i=0;i<count;i++){
            list.add(i);
        }

        Integer[] array = new Integer[count];
        for (int i=0;i<count;i++){
            Random random = new Random();
            int index = random.nextInt(list.size());
            array[i] = list.get(index);
            list.remove(index);
        }
        return array;
    }
}
